home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 18 / CU Amiga Magazine's Super CD-ROM 18 (1997)(EMAP Images)(GB)[!][issue 1998-01].iso / CUCD / Online / CNetDemo / cnet / sdk / Examples / identdtest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-09-04  |  27.4 KB  |  788 lines

  1. /************************************************************************
  2.  *    CNet/3 and CNet/4  C language interface routines and examples     *
  3.  *                                                                      *
  4.  *  copyright © 1996 ZenMetal Software ... this code may be freely      *
  5.  *  distributed to and used by registered CNet owners EXCLUSIVELY.      *
  6.  *  Other distribution is in violation of copyright laws.               *
  7.  ************************************************************************/
  8.  
  9.  
  10. /************************************************************************
  11.  *                          Function prototypes                         *
  12.  ************************************************************************/
  13. void        CallHost( UBYTE c );
  14. void        ShutDown( char *spawn );
  15. void        GetOut( void );
  16. int        intGetOut( void );
  17. void        LoadError( void );
  18.  
  19. void DisplayIdentD( void );
  20.  
  21.  
  22. /************************************************************************
  23.  *                           Global Variables                           *
  24.  ************************************************************************/
  25. struct MsgPort         *replyp;    /* Some communication details ...    */
  26. struct CPort           *cport;
  27. struct CMessage        cmess;
  28. struct MainPort        *myp;        /* Pointer to CNet port--ALL info!    */
  29. struct PortData        *z;
  30. char                     **bm;
  31. struct Library         *CNetBase = NULL;
  32. struct SignalSemaphore *SEM;
  33.  
  34.  
  35.  
  36. /************************************************************************
  37.  *                             Main routine                             *
  38.  ************************************************************************/
  39. void main( int argc, char **argv )
  40. {
  41.     int x=0;
  42.  
  43.     Forbid();
  44.     if(argc > 1) cport = (struct CPort *)FindPort( argv[1] );
  45.     Permit();
  46.  
  47.     if( argc<2 || !(cport) ) {
  48.         printf("This is a CNet C program.\n");
  49.         exit(0);
  50.         }
  51.  
  52.     if( !(replyp = CreatePort( 0,0 )))
  53.         exit(0);
  54.  
  55.     cmess.cn_Message.mn_ReplyPort   = replyp;
  56.     cmess.cn_Message.mn_Length      = sizeof( struct CMessage );
  57.     cmess.cn_Message.mn_Node.ln_Name= "cstuff";
  58.  
  59.     // CNet version check
  60.     if( cport->ack != 30 ) {
  61.         cport->ack = 1;
  62.         LoadError();
  63.         }
  64.  
  65.     cport->ack = 0;
  66.  
  67.     z    = cport->zp;
  68.     myp  = cport->myp;
  69.     SEM  = myp->SEM;
  70.     bm   = z->bm;
  71.  
  72.     if( !(CNetBase = OpenLibrary( "cnet.library", 4 )) ) // <- NOTE version 4 - can be changed to 3 to make compatible with older CNet releases!
  73.         LoadError();
  74.  
  75.     atexit(GetOut); // inserts an exit trap.  When exit() is called, the
  76.                    // code in GetOut() is invoked.
  77.  
  78.     onbreak(intGetOut); // this break trap causes the program to exit when
  79.                   // the program receives a break (CTRL-C) signal
  80.  
  81. /************************************************************************
  82.  *           End of CNet setup - YOUR CUSTOM CODE STARTS HERE           *
  83.  ************************************************************************/
  84.  
  85.     DisplayIdentD();
  86.     for(x=0;x<20;x++) // loop and insert 20 identd entries
  87.         {
  88.         if(AddIdentdUser(z->InPort, x) == 0)
  89.             {
  90.             PutText("Added identd entry!\n");
  91.             }
  92.         else
  93.             {
  94.             PutText("Error Adding identd entry!\n");
  95.             }
  96.         }
  97.  
  98.     DisplayIdentD(); // display current identd sockets
  99.  
  100.     for(x=0;x<20;x++) // perform lookup of each inserted identd entry
  101.         {
  102.         sprintf(z->ABuffer, "Found socket identd socket %d entry for port %d\n", x, LookupIdentd(x));
  103.         PutA();
  104.         RemoveIdentdUser(x); // remove identd entry
  105.         }
  106.  
  107.     DisplayIdentD(); // display to ensure all have been removed
  108.  
  109. /************************************************************************
  110.  *                         exit back to CNet!
  111.  ************************************************************************/
  112.  
  113.     // note that an exit trap calling GetOut() has been inserted previously to
  114.     // facilitate resource cleanup..
  115.     exit(0);
  116. }
  117.  
  118.  
  119. /**************************************************************************
  120.  *       Routine called if Load error (wrong CNet version, etc,...        *
  121.  **************************************************************************/
  122. void LoadError( void )
  123. {
  124.     if(replyp)
  125.         {
  126.         // Use while(GetMsg(replyp) here to get any pending msgs before deleting port!
  127.         DeletePort( replyp );
  128.         }
  129.     exit(0);
  130. }
  131.  
  132.  
  133.  
  134. /**************************************************************************
  135.  *       An added function to call GetOut() for onbreak() support         *
  136.  **************************************************************************/
  137. int intGetOut( void )
  138. {
  139.     exit(0);
  140.     return 0;
  141. }
  142.  
  143.  
  144. /************************************************************************
  145.  *                           Generic EXIT code                          *
  146.  ************************************************************************/
  147. void GetOut( void )
  148. {
  149.     ShutDown( NULL );
  150.  
  151.     // clean up message ports opened by this door.
  152.     if(replyp)
  153.         {
  154.         // delete the port that CNet doors open for CallHost() messages
  155.         DeletePort( replyp );
  156.         }
  157.  
  158. }
  159.  
  160.  
  161. /**************************************************************************
  162.  *                         another file to run?                           *
  163.  **************************************************************************/
  164. void ShutDown( char *spawn )
  165. {
  166.     /* spawn = full path/file to run */
  167.     if( spawn )
  168.         strcpy( z->CSpawn, spawn );
  169.  
  170.     CallHost( 0 );
  171. }
  172.  
  173.  
  174. void CallHost( UBYTE c )
  175. {
  176.     cmess.command = c;
  177.     PutMsg  ( (struct MsgPort *)cport, (struct Message *)&cmess );
  178.     WaitPort( replyp );
  179.     GetMsg  ( replyp );
  180. }
  181.  
  182. void PutText( char *text )
  183. {
  184.     cmess.arg1 = (ULONG)text;    /* text to print        */
  185.     CallHost( 1 );
  186. }
  187.  
  188. void PutA( void )
  189. {
  190.     PutText( z->ABuffer );
  191. }
  192.  
  193.  
  194. /**************************************************************************
  195.  *    ENTERLINE FLAGS:                                                    *
  196.  *    Construct by ORing the following bit defines:                       *
  197.  *                                                                        *
  198.  * ie. EnterLine(3, ELINE_ALLCAPS|ELINE_INPOUTBOX, "My Prompt>");         *
  199.  *                                                                        *
  200.  *     FLAGS:                                                             *
  201.  *     ------                                                             *
  202.  *     ELINE_ALLCAPS       = All capitalized                              *
  203.  *     ELINE_FILENAME      = FILENAME.  Don't allow =":; or asterisk      *
  204.  *     ELINE_USEINBUFF     = Begin with existing z.InBuffer               *
  205.  *     ELINE_NOLEADSPACE   = Chop leading spaces                          *
  206.  *     ELINE_CAPWORDSTART  = Force 1st letter of word caps                *
  207.  *     ELINE_RESTWORDLOWER = Force all others lower case                  *
  208.  *     ELINE_NUMBERSONLY   = Numeric input only                           *
  209.  *     ELINE_INPUTBOX      = Print input box (terminated with . )         *
  210.  *     ELINE_ALLOWMCI      = DO allow MCI                                 *
  211.  *     ELINE_HANDLESPECIAL = HANDLES/SPECIAL.  Don't allow ^_`{|}~@       *
  212.  *     ELINE_XSLASHSTART   = Exit for . or / at beginning of line         *
  213.  *     ELINE_XBKSPACESTART = Exit for backspace at beginning of line      *
  214.  *     ELINE_NOOLMS        = Do not allow OLM's to appear while editing   *
  215.  *     ELINE_ALLOWCHAT     = Allow Chat break in at this prompt. COMMAND  *
  216.  *                           PROMPT.                                      *
  217.  *     ELINE_NOSPACES      = Don't allow SPACES                           *
  218.  *     ELINE_NOCURSORMOVE  = DON'T ALLOW MOVEMENT                         *
  219.  *     ELINE_NOSLASHES     = Don't allow forward slash                    *
  220.  *                                                                        *
  221.  *  NOTE: The old "numeric" flag values still work 100% ..                *
  222.  **************************************************************************/
  223. int EnterLine( UBYTE len, ULONG flags, char *prompt )
  224. {
  225.     cmess.arg1 = (ULONG)len;     /* how many chars max to input    */
  226.     cmess.arg2 = (ULONG)flags;   /* flags describing required input handling */
  227.     cmess.arg3 = (ULONG)prompt;  /* text to print before input    */
  228.     CallHost( 2 );               /* result is in z->InBuffer    */
  229.  
  230.     return( (int)strlen( z->InBuffer ));
  231. }
  232.  
  233.  
  234. /**************************************************************************
  235.  *                       Stop until a key is pressed                      *
  236.  **************************************************************************/
  237. char OneKey( void )
  238. {
  239.     CallHost( 3 );
  240.     return( (char)cmess.result );    /* function returns ASCII value of key pressed */
  241. }
  242.  
  243.  
  244. /**************************************************************************
  245.  *
  246.  **************************************************************************/
  247. void EnterPassword( UBYTE len )
  248. {
  249.     cmess.arg1 = (ULONG)len;    /* max number of characters */
  250.     CallHost( 4 );
  251. }
  252.  
  253. /**************************************************************************
  254.  *                 Check z->InBuffer for Chat, OLM, etc                   *
  255.  **************************************************************************/
  256. long CommonCommands( void )
  257. {
  258.     CallHost( 5 );
  259.     return( (long)cmess.result );
  260. }
  261.  
  262.  
  263. /**************************************************************************
  264.  *
  265.  **************************************************************************/
  266. UBYTE ReadFile( char *path, UBYTE flags )
  267. {
  268.     cmess.arg1 = (ULONG)path;
  269.     cmess.arg2 = (ULONG)flags;          /* 1 = print File Not Found */
  270.     CallHost( 6 );
  271.     return( (UBYTE)cmess.result );      /* returns FALSE if File Not Found */
  272. }
  273.  
  274. /**************************************************************************
  275.  *        Sets the "Action" or "Where" field for the user's port          *
  276.  *      ** remember to retain and restore the previous z->DOING **        *
  277.  **************************************************************************/
  278. void SetDoing( char *what )
  279. {
  280.     cmess.arg1 = (ULONG)what;
  281.     CallHost( 7 );
  282. }
  283.  
  284.  
  285. /**************************************************************************
  286.  *Invokes the CNet editor according to user's preference of line or Visual*
  287.  **************************************************************************/
  288. void CallEditor( short max, short inlines )
  289. {
  290.     cmess.arg1 = (ULONG)max;    /* Maximum number of lines (250)*/
  291.     cmess.arg2 = (ULONG)inlines;    /* TRUE/FALSE use existing _edbuff? */
  292.     CallHost( 8 );
  293. }
  294.  
  295. /**************************************************************************
  296.  *             Read text file with MCI/graphic interpretation             *
  297.  **************************************************************************/
  298. UBYTE ReadGraphics( char *path, char flags )
  299. {
  300.     cmess.arg1 = (ULONG)path;
  301.     cmess.arg2 = (ULONG)flags;    /* 1 = print File Not Found    */
  302.     CallHost( 9 );
  303.     return( (UBYTE)cmess.result );        /* FALSE if File Not Found    */
  304. }
  305.  
  306. /**************************************************************************
  307.  *  Construct a date in CNet format - like that seen in the port titlebar *
  308.  **************************************************************************/
  309. void MakeDate( struct IsDate *date, char *output )
  310. {
  311.     cmess.arg1 = (ULONG)date;
  312.     cmess.arg2 = (ULONG)output;
  313.     CallHost( 10 );
  314. }
  315.  
  316.  
  317. /**************************************************************************
  318.  *                     Load userdata for account "id"                     *
  319.  **************************************************************************/
  320. UBYTE ReadAccount( short id, struct UserData *user )
  321. {
  322.     cmess.arg1 = (ULONG)id;
  323.     cmess.arg2 = (ULONG)user;
  324.     CallHost( 11 );
  325.     return( (UBYTE)cmess.result );
  326. }
  327.  
  328. /**************************************************************************
  329.  *           Saves an account after editing/changing attributes           *
  330.  **************************************************************************/
  331. UBYTE SaveAccount( struct UserData *user, short id )
  332. {
  333.     cmess.arg1 = (ULONG)user;
  334.     cmess.arg2 = (ULONG)id;
  335.     CallHost( 12 );
  336.     return( (UBYTE)cmess.result );
  337. }
  338.  
  339. /**************************************************************************
  340.  *         add charge amount "a" to charge schedule number "n"            *
  341.  **************************************************************************/
  342. UBYTE AddCharge( short n, short a )
  343. {
  344.     cmess.arg1 = (ULONG)n;
  345.     cmess.arg2 = (ULONG)a;
  346.     CallHost( 13 );
  347.     return( (UBYTE)cmess.result );
  348. }
  349.  
  350. /**************************************************************************
  351.  *
  352.  **************************************************************************/
  353. UBYTE CheckBalance( short n, short a )
  354. {
  355.     cmess.arg1 = (ULONG)n;
  356.     cmess.arg2 = (ULONG)a;
  357.     CallHost( 14 );
  358.     return( (UBYTE)cmess.result );
  359. }
  360.  
  361. /***************************************************************************
  362.  * Get text from user.  Results are placed in z.GBuffer[] array of strings *
  363.  * note that there are 16 lines MAX and each line may hold up to 80        *
  364.  * characters                                                              *
  365.  ***************************************************************************/
  366. int EnterText( char firstchar, short maxchars, short perline, short maxlines )
  367. {
  368.     cmess.arg1 = (ULONG)firstchar;
  369.     cmess.arg2 = (ULONG)maxchars;
  370.     cmess.arg3 = (ULONG)perline;
  371.     cmess.arg4 = (ULONG)maxlines;
  372.     CallHost( 15 );
  373.     return( (int)cmess.result );
  374. }
  375.  
  376. /**************************************************************************
  377.  *
  378.  **************************************************************************/
  379. long ConferenceWait( short a )
  380. {
  381.     cmess.arg1 = (ULONG) a;
  382.     CallHost( 16 );
  383.     return( (long)cmess.result );
  384. }
  385.  
  386.  
  387. /****************************************************************************
  388.  * Update the current time, load the user's bbstext translation, charges    *
  389.  * If the user has little time remaining, print "you have xx minutes left", *
  390.  * force Events to be checked for pending event execution..                 *
  391.  ****************************************************************************/
  392. void CheckChanges( void )
  393. {
  394.     CallHost( 17 );
  395. }
  396.  
  397.  
  398. /**************************************************************************
  399.  *      Converts a CNet access/range string to a packed LONG value        *
  400.  **************************************************************************/
  401. long ConvertAccess( char *s )
  402. {
  403.     cmess.arg1 = (ULONG)s;
  404.     CallHost( 18 );
  405.     return( (long)cmess.result );
  406. }
  407.  
  408.  
  409. /**************************************************************************
  410.  * return the number of bytes free on device specified by s               *
  411.  * if q==0, the result is displayed to the user by GetFree()              *
  412.  **************************************************************************/
  413. long GetFree( char *s, UBYTE q )
  414. {
  415.     cmess.arg1 = (ULONG)s;
  416.     cmess.arg2 = (ULONG)q;
  417.     CallHost( 19 );
  418.     return( (long)cmess.result );
  419. }
  420.  
  421. /**************************************************************************
  422.  *  Forces CNet to flush/check it's buffers and parse/update the keyboard *
  423.  *  buffers                                                               *
  424.  **************************************************************************/
  425. void CheckFlowControl( void )
  426. {
  427.     CallHost( 21 );
  428. }
  429.  
  430. /**************************************************************************
  431.  * list the contents of a directory (the user will be prompted for        *
  432.  * directory name).                                                       *
  433.  *                                                                        *
  434.  * options: a = allow selection of files to user's select list            *
  435.  *                                                                        *
  436.  *          b = 1: select and download immediately                        *
  437.  *              2: allow wildcard pattern                                 *
  438.  *                                                                        *
  439.  *          c = list files newer than the date specified by c             *
  440.  *              c is a properly filled out Cnet IsDate structure          *
  441.  **************************************************************************/
  442. long ListDir( UBYTE a, UBYTE b, struct IsDate *c )
  443. {
  444.     cmess.arg1 = (ULONG)a;
  445.     cmess.arg2 = (ULONG)b;
  446.     cmess.arg3 = (ULONG)c;
  447.     CallHost( 22 );
  448.     return( (long)cmess.result );
  449. }
  450.  
  451.  
  452. /**************************************************************************
  453.  * Read the next base/udbase message                                      *
  454.  **************************************************************************/
  455. UBYTE Rnext( void )
  456. {
  457.     CallHost( 24 );
  458.     return( (UBYTE)cmess.result );
  459. }
  460.  
  461. /***************************************************************************
  462.  * Parse the contents of z->InBuffer into z->pitems.  Parses up to numargs *
  463.  * items                                                                   *
  464.  ***************************************************************************/
  465. void ParseCommandLine( UBYTE numargs )
  466. {
  467.     cmess.arg1 = (ULONG)numargs;
  468.     CallHost( 25 );
  469. }
  470.  
  471.  
  472. /**************************************************************************
  473.  *  Takes the contents of z->InBuffer and searches for a matching command *
  474.  *  in menu "num" of BBSMENU.                                             *
  475.  **************************************************************************/
  476. short FindCommand( short num )
  477. {
  478.     cmess.arg1 = (ULONG) num;
  479.     CallHost( 26 );
  480.     return( (short)cmess.result );
  481. }
  482.  
  483. /**************************************************************************
  484.  * Open the filename specified by a, seek to position b in the file       *
  485.  * and display the contents of the file from point b to EOF               *
  486.  **************************************************************************/
  487. void ReadMessagePoint( char *a, long b )
  488. {
  489.     cmess.arg1 = (ULONG) a;
  490.     cmess.arg2 = (ULONG) b;
  491.     CallHost( 27 );
  492. }
  493.  
  494. /**************************************************************************
  495.  * Use the CNet editor to edit the file specified by "file"               *
  496.  **************************************************************************/
  497. void EditMessage( char *file )
  498. {
  499.     cmess.arg1 = (ULONG) file;
  500.     CallHost( 28 );
  501. }
  502.  
  503. /***************************************************************************
  504.  * Load the text from the file-handle given and insert it into the current *
  505.  * port's editor file                                                      *
  506.  ***************************************************************************/
  507. void LoadText( BPTR fh )
  508. {
  509.     cmess.arg1 = (ULONG) fh;
  510.     CallHost( 29 );
  511. }
  512.  
  513.  
  514. /**************************************************************************
  515.  *    1000000 mics = 1 second                                                *
  516.  **************************************************************************/
  517. char WaitForInput( long mics )
  518. {
  519.     cmess.arg1 = (ULONG) mics;
  520.     CallHost( 31 );
  521.     return( (char)cmess.result );
  522. }
  523.  
  524.  
  525. /**************************************************************************
  526.  *                       Select and download a file.                      *
  527.  *                                                                        *
  528.  * file  = full path/filename                                             *
  529.  *                                                                        *
  530.  * flags = 0 -> select without immediate download                         *
  531.  *       = 1 -> select and download immediately                           *
  532.  *                                                                        *
  533.  * flag values below are new for v4.11                                    *
  534.  *                                                                        *
  535.  *       = 2 -> delete file after downloading/no immediate download       *
  536.  *       = 3 -> delete file after downloading/download immediate.         *
  537.  **************************************************************************/
  538. UBYTE SelectAndDownload( char *file, UBYTE flags )
  539. {
  540.     cmess.arg1 = (ULONG)file;
  541.     cmess.arg2 = (ULONG)flags;
  542.     CallHost( 39 );
  543.     return( (UBYTE)cmess.result );
  544. }
  545.  
  546.  
  547. /**************************************************************************
  548.  * file: the ".vde" filename, without the ".vde"!                         *
  549.  * data: pointer to the structure you are going to edit                   *
  550.  * size: structure length in bytes                                        *
  551.  *                                                                        *
  552.  * returns: TRUE  if structure has been changed                           *
  553.  *          FALSE otherwise                                               *
  554.  **************************************************************************/
  555. short VisualDataEditor( char *file, void *data, long size )
  556. {
  557.     cmess.arg1 = (ULONG)file;
  558.     cmess.arg2 = (ULONG)data;
  559.     cmess.arg3 = (ULONG)size;
  560.     CallHost( 40 );
  561.     return( (short)cmess.result );
  562. }
  563.  
  564. /**************************************************************************
  565.  * In preparation for an ExtUpload, this function                         *
  566.  * sets the minimum number of free bytes to maintain on the    drive.        *
  567.  **************************************************************************/
  568. void ExtSetMinFree( long free )
  569. {
  570.     cmess.arg1 = (ULONG)free;
  571.     CallHost( 42 );
  572. }
  573.  
  574.  
  575. /**************************************************************************
  576.  * In preparation for an ExtDownload or an ExtUpload, this function       *
  577.  * sets the protocol to be used.  If you send NULL, it will allow the     *
  578.  * user to choose his OWN protocol.                                       *
  579.  *                                                                        *
  580.  * Otherwise, you may select 'a' to be the first letter of a valid        *
  581.  * system protocol (from BBSPROTO file), such as 'x', 'z', etc.           *
  582.  *                                                                        *
  583.  * TRUE will be returned if a protocol is selected and ready, FALSE       *
  584.  * if there is a problem.                                                 *
  585.  **************************************************************************/
  586. UBYTE ExtSetProtocol( char a )
  587. {
  588.     cmess.arg1 = (ULONG)a;
  589.     CallHost( 43 );
  590.     return( (UBYTE)cmess.result );
  591. }
  592.  
  593.  
  594.  
  595. /**************************************************************************
  596.  * This routine allows the user to download the SINGLE file specified     *
  597.  * by the FULL PATH 'args'.                                               *
  598.  *                                                                        *
  599.  *    Currently, NULL is always returned.                                    *
  600.  **************************************************************************/
  601. char *ExtDownload( char *args )
  602. {
  603.     cmess.arg1 = (ULONG)args;
  604.     CallHost( 44 );
  605.     return( (char *)cmess.result );
  606. }
  607.  
  608.  
  609. /**************************************************************************
  610.  * This routine allows the user to upload the file specified by           *
  611.  * 'args'.  The path for uploading will be taken from the path            *
  612.  * in 'args'.  If you do NOT specify a path, the file(s) will             *
  613.  * appear in the user's HOME directory.                                   *
  614.  *                                                                        *
  615.  * Note that with batch protocols like ZMODEM, the filename(s) are        *
  616.  * taken from the header packet information, and may NOT be the           *
  617.  * same as what you have requested the user upload.  For this reason,     *
  618.  * you should have uploads occur in a TEMP directory, and search that     *
  619.  * directory yourself for new files.                                      *
  620.  *                                                                        *
  621.  * Currently, NULL is always returned.                                    *
  622.  **************************************************************************/
  623. char *ExtUpload( char *args )
  624. {
  625.     cmess.arg1 = (ULONG)args;
  626.     CallHost( 45 );
  627.     return( (char *)cmess.result );
  628. }
  629.  
  630. /**************************************************************************
  631.  * Write myp->Key[] to bbs.ukeys in a CNet friendly manner
  632.  * getsem: 0 = do not lock the key semaphore
  633.  *         1 = lock the key semaphore before writing
  634.  *
  635.  * the key semaphore is myp->SEM[1] so, if you have already performed
  636.  * ObtainSemaphore(myp->SEM[1]), then use WriteBBSKeys(0)
  637.  * if you have not locked the semaphore, use WriteBBSKeys(1)
  638.  *
  639.  * notes:
  640.  *
  641.  * if a user's account data is altered, you must also copy the
  642.  * handle, MailID (AKA UUCP ID), Real Name, etc, to myp->Key[AccountNumber]
  643.  *
  644.  * Please see the structure definition for KeyElement4 in users.h to
  645.  * see what data is saved to myp->Key[x]
  646.  *
  647.  * After doing this, the key array must be written to bbs.ukeys.  This
  648.  * function facilitates all the grunt work of writing the key array
  649.  * in the proper size.
  650.  *
  651.  **************************************************************************/
  652. BYTE WriteUKeys( BYTE getsem )
  653. {
  654.     CallHost( 58 );
  655.     return( (BYTE)cmess.result );
  656. }
  657.  
  658. void DoANSI( UBYTE n, USHORT a, USHORT b)
  659. {
  660.     cmess.arg1 = (ULONG)n;
  661.     cmess.arg2 = (ULONG)a;
  662.     cmess.arg3 = (ULONG)b;
  663.     CallHost( 59 );
  664.     return;
  665. }
  666.  
  667. void DoANSIOut( UBYTE n)
  668. {
  669.     cmess.arg1 = (ULONG)n;
  670.     CallHost( 60 );
  671.     return;
  672. }
  673.  
  674.  
  675. /**************************************************************************
  676.  * Print the prompt string passed as "a" and return the user's            *
  677.  * YES or NO equivalent result.  1=YES, 2=NO                              *
  678.  **************************************************************************/
  679. UBYTE PutQ( char *a )
  680. {
  681.     PutText( a );
  682.     return (UBYTE)(z->MCIcreg[0][0]=='1') ;
  683. }
  684.  
  685.  
  686. /**************************************************************************
  687.  * Isn't it obvious enough? ;-)
  688.  **************************************************************************/
  689. void DoReturn( void )
  690. {
  691.     PutText("\n");
  692. }
  693.  
  694.  
  695. /**************************************************************************
  696.  * Create the editor filename used for the current port and place it      *
  697.  * in the string array passed as "path"                                   *
  698.  **************************************************************************/
  699. void MakeEd( char *path )
  700. {
  701.     sprintf( path, "%s_edbuff%d", myp->gc.ZIPpath, z->InPort );
  702. }
  703.  
  704.  
  705. /**************************************************************************
  706.  * Delete the editor file                                                 *
  707.  **************************************************************************/
  708. void DeleteEd( void )
  709. {
  710.     char    filename[80];
  711.  
  712.     MakeEd    ( filename ) ;
  713.     DeleteFile( filename ) ;
  714. }
  715.  
  716. /**************************************************************************
  717.  * Open the file used for the editor and return the filehandle (BPTR)     *
  718.  **************************************************************************/
  719. BPTR OpenEd( long mode )
  720. {
  721.     char    filename[80];
  722.  
  723.     MakeEd( filename );
  724.  
  725.     return Open( filename, mode );
  726. }
  727.  
  728. /**************************************************************************
  729.  * insert the contents of the file belonging to filehandle "fp" into      *
  730.  * the current port's editor file                                         *
  731.  **************************************************************************/
  732. void PrepEditor( BPTR fp )
  733. {
  734.     BPTR    kp;
  735.     char    buff[100];
  736.  
  737.     if( fp ) {
  738.         if( kp = OpenEd( MODE_NEWFILE ) ) {
  739.             while( FGets( fp, buff, 82 ) && buff[0]!=26 )
  740.                    FPuts( kp, buff     ) ;
  741.  
  742.             Close( kp );
  743.         }
  744.     }
  745.     else    DeleteEd();
  746. }
  747.  
  748. /**************************************************************************
  749.  * Save the contents of the current port's editor file into the file      *
  750.  * belonging to filehandle "fp"                                           *
  751.  **************************************************************************/
  752. void SaveEditor( BPTR fp, UBYTE eof )
  753. {
  754.     BPTR    kp;
  755.     char    buff[100];
  756.  
  757.     if( kp = OpenEd( MODE_OLDFILE ) ) {
  758.         while( FGets( kp, buff, 82 ) && buff[0]!=26 )
  759.                FPuts( fp, buff     ) ;
  760.  
  761.         Close( kp );
  762.  
  763.         DeleteEd();
  764.     }
  765.  
  766.     if( eof ) FPuts( fp, "\032\n" );
  767. }
  768.  
  769.  
  770. void DisplayIdentD( void )
  771. {
  772.     if(myp->MPE->idd)
  773.         {
  774.         struct IdentdData *iddptr=myp->MPE->idd;
  775.         // walk the list of identd data and print specifics
  776.         while(iddptr)
  777.             {
  778.             sprintf(z->ABuffer, "Socket number: %ld, CNet Owner Port: %ld\n", iddptr->socket, iddptr->port);
  779.             PutA();
  780.             iddptr=iddptr->next;
  781.             }
  782.         }
  783.     else
  784.         {
  785.         PutText("No identd entries\n");
  786.         }
  787. }
  788.